package com.framework.file.repository;

import com.framework.common.repository.BaseJpaRepository;
import com.framework.file.model.FileManage;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @description: 档案管理 Repository
 * @author: lizurong
 * @version: 1.0
 * @date: 2021-04-01 16:53:14
 */

@Repository
public interface FileManageRepository extends BaseJpaRepository<FileManage, String> {
    FileManage getTopByFolderName(String folderName);

    List<FileManage> getAllByTreeLevelEquals(Integer treeLevel);

    @Query("select t from FileManage t where t.pid=:id and (t.description <> 'isCom' or t.description is null )")
    List<FileManage> getTopTree(@Param("id") String id);

    @Query("select t from FileManage t where  t.treeLevel >:treeLevel")
    List<FileManage> getChildTree(@Param("treeLevel") Integer treeLevel);

    //treeLevel =0 使用
    @Query("select t.id from FileManage t where t.pid=:pid")
    String getIdByPid(@Param("pid") String pid);

    @Query("select t from FileManage t where t.pid=:pid and t.folderName=:folderName")
    FileManage getByPidAndFolderName(@Param("pid") String pid, @Param("folderName") String folderName);

}
